package org.example.doctorapi.sms;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.DigestUtils;

@Data
@Configuration
public class SmsConfig {
    @Value("${sms.base_url}")
    private String BASE_URL;
    @Value("${sms.account_sid}")
    private String ACCOUNT_SID;
    @Value("${sms.auth_token}")
    private String AUTH_TOKEN;
    @Value("${sms.rep_data_type}")
    private String REQ_DATA_TYPE;
    @Value("${sms.template_id}")
    private String TEMPLATE_ID;
    public String createCommonParam(String sid,String token){
        long millis = System.currentTimeMillis();
        String sin = DigestUtils.md5DigestAsHex((sid + token + millis).getBytes());
        return "&timestamp"+millis+"&sin"+sin+"$respDataType"+getREQ_DATA_TYPE();
    }
}
